home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Digitalfoto 118
/
Digitalfoto 118.iso
/
mac
/
programas
/
00
/
start.swf
/
scripts
/
__Packages
/
v2bScroller.as
Wrap
Text File
|
2009-11-16
|
11KB
|
364 lines
class v2bScroller extends mx.core.UIComponent
{
var mouseMoveListener = new Object();
var scroll_direction = "vertical";
var snap_offset = 0;
var scroll_percentage = 0;
var use_invisible_mask = false;
var auto_read_target_size = true;
var _enabled = false;
var read_target_size_interval = 60;
var target_start_x = 0;
var target_start_y = 0;
var target_height = 0;
var target_width = 0;
var scroller_height = 0;
var scroller_width = 0;
function v2bScroller()
{
super();
this.onUnload = function()
{
if(this.oSipDWs != undefined)
{
this.oSipDWs.removeMovieClip();
this.oSipDWs = undefined;
}
};
}
function set autoReadTargetSize(val)
{
this.auto_read_target_size = val;
this.invalidate();
}
function get autoReadTargetSize()
{
return this.auto_read_target_size;
}
function set useInvisibleMask(val)
{
this.use_invisible_mask = val;
this.invalidate();
}
function get useInvisibleMask()
{
return this.use_invisible_mask;
}
function set enabled(val)
{
}
function get enabled()
{
return this._enabled;
}
function set snapOffset(val)
{
this.snap_offset = val;
this.invalidate();
}
function get snapOffset()
{
return this.snap_offset;
}
function set scrollDirection(val)
{
this.scroll_direction = val;
this.invalidate();
}
function get scrollDirection()
{
return this.scroll_direction;
}
function set viewAreaWidth(val)
{
this.view_area_width = val;
this.invalidate();
}
function get viewAreaWidth()
{
return this.view_area_width;
}
function set viewAreaHeight(val)
{
this.view_area_height = val;
this.invalidate();
}
function get viewAreaHeight()
{
return this.view_area_height;
}
function set targetMovieClip(val)
{
var _loc3_ = String(this.target_mc);
if(typeof val == "string")
{
this.target_mc = this._parent[val];
}
else
{
this.target_mc = val;
}
if(this.oSipDWs != undefined)
{
this.oSipDWs.removeMovieClip();
this.oSipDWs = undefined;
}
this.target_start_x = Math.round(this.target_mc._x);
this.target_start_y = Math.round(this.target_mc._y);
this.target_mc._x = this.target_start_x;
this.target_mc._y = this.target_start_y;
this.invalidate();
}
function get targetMovieClip()
{
return this.target_mc;
}
function set scrollPercentage(val)
{
if(val < 0)
{
val = 0;
}
else if(val > 100)
{
val = 100;
}
this.scroll_percentage = val;
this.invalidate();
}
function get scrollPercentage()
{
return this.scroll_percentage;
}
function set targetHeight(val)
{
this.target_height = val;
this.invalidate();
}
function get targetHeight()
{
return this.target_height;
}
function set targetWidth(val)
{
this.target_width = val;
this.invalidate();
}
function get targetWidth()
{
return this.target_width;
}
function setSize(s_width, s_height)
{
if(s_width != null && s_width != undefined)
{
this.scroller_width = s_width;
this.__width = this.scroller_width;
}
if(s_height != null && s_height != undefined)
{
this.scroller_height = s_height;
this.__height = this.scroller_height;
}
this.invalidate();
}
function init()
{
super.init();
}
function createChildren()
{
var _loc2_ = this;
this.slider_mc.onPress = this.slider_onPress;
this.slider_mc.onRelease = this.slider_mc.onReleaseOutside = this.slider_onRelease;
this.slider_mc.onRollOver = this.slider_onRollOver;
this.slider_mc.onRollOut = this.slider_onRollOut;
this.size();
}
function draw()
{
super.draw();
}
function size()
{
super.size();
if(this.scroll_direction == "vertical")
{
this.slider_mc._rotation = 0;
this.slider_mc._y = 0;
this.track_state_mc._rotation = 0;
this.track_state_mc._y = 0;
}
else
{
this.slider_mc._rotation = -90;
this.slider_mc._y = this.slider_mc._height;
this.track_state_mc._rotation = -90;
this.track_state_mc._y = this.track_state_mc._height;
}
this.invalidate();
}
function invalidate()
{
super.invalidate();
var _loc3_ = this;
this.scroller_width = Math.round(this.__width);
this.scroller_height = Math.round(this.__height);
if(this.target_mc == undefined || this.target_mc._x == undefined || this.view_area_height == undefined || this.view_area_width == undefined)
{
if(this.oSipDWs != undefined)
{
this.oSipDWs.removeMovieClip();
this.oSipDWs = undefined;
}
this._visible = false;
this._enabled = false;
return undefined;
}
if(!this.use_invisible_mask)
{
if(this.oSipDWs == undefined)
{
this.addMask();
this.target_mc.setMask(this.oSipDWs);
}
}
else if(this.oSipDWs != undefined)
{
this.oSipDWs.removeMovieClip();
this.oSipDWs = undefined;
}
this.update();
if(this.auto_read_target_size)
{
this.read_target_size_delay = setInterval(_loc3_,"getTargetSize",this.read_target_size_interval);
}
else
{
clearInterval(this.read_target_size_delay);
}
}
function addMask()
{
var _loc2_ = "mask_" + Math.round(Math.random() * 10000000);
while(this._parent[_loc2_] != undefined)
{
_loc2_ = "mask_" + Math.round(Math.random() * 10000000);
}
this.oSipDWs = this.target_mc._parent.createEmptyMovieClip(_loc2_,this.target_mc._parent.getNextHighestDepth());
this.oSipDWs.beginFill(0);
this.oSipDWs.moveTo(0,0);
this.oSipDWs.lineTo(0,100);
this.oSipDWs.lineTo(100,100);
this.oSipDWs.lineTo(100,0);
this.oSipDWs.endFill();
this.oSipDWs._x = this.target_start_x;
this.oSipDWs._y = this.target_start_y;
}
function setMaskSize()
{
this.oSipDWs._width = this.view_area_width;
this.oSipDWs._height = this.view_area_height;
}
function update()
{
if(this.auto_read_target_size)
{
this.target_height = Math.ceil(this.target_mc._height);
this.target_width = Math.ceil(this.target_mc._width);
}
if(!this.use_invisible_mask)
{
this.setMaskSize();
}
if(this.scroll_direction == "vertical")
{
if(this.target_height + this.snap_offset < this.view_area_height)
{
this._visible = false;
this._enabled = false;
this.scroll_percentage = 0;
}
else
{
this._visible = true;
this._enabled = true;
}
}
else if(this.target_width + this.snap_offset < this.view_area_width)
{
this._visible = false;
this._enabled = false;
this.scroll_percentage = 0;
}
else
{
this._visible = true;
this._enabled = true;
}
if(this.scroll_direction == "vertical")
{
this.track_state_mc._height = this.scroller_height;
this.slider_mc._y = Math.round((this.scroller_height - this.slider_mc._height) * this.scroll_percentage / 100);
this.target_mc._y = Math.round(this.target_start_y - (this.target_height + this.snap_offset - this.view_area_height) * this.scroll_percentage / 100);
}
else
{
this.track_state_mc._rotation = 0;
this.track_state_mc._height = this.scroller_width;
this.track_state_mc._rotation = -90;
this.slider_mc._x = Math.round((this.scroller_width - this.slider_mc._width) * this.scroll_percentage / 100);
this.target_mc._x = Math.round(this.target_start_x - (this.target_width + this.snap_offset - this.view_area_width) * this.scroll_percentage / 100);
}
}
function slider_onPress()
{
this.gotoAndStop("pressed");
if(this._parent.scroll_direction == "vertical")
{
this.startDrag(false,0,0,0,this._parent.scroller_height - this._height);
}
else
{
this.startDrag(false,0,this._height,this._parent.scroller_width - this._width,this._height);
}
this.onMouseMove = function()
{
if(this._parent.scroll_direction == "vertical")
{
this._parent.scroll_percentage = this._parent.slider_mc._y * 100 / (this._parent.scroller_height - this._parent.slider_mc._height);
this._parent.target_mc._y = Math.round(this._parent.target_start_y - (this._parent.target_height + this._parent.snap_offset - this._parent.view_area_height) * this._parent.scroll_percentage / 100);
}
else
{
this._parent.scroll_percentage = this._parent.slider_mc._x * 100 / (this._parent.scroller_width - this._parent.slider_mc._width);
this._parent.target_mc._x = Math.round(this._parent.target_start_x - (this._parent.target_width + this._parent.snap_offset - this._parent.view_area_width) * this._parent.scroll_percentage / 100);
}
};
}
function slider_onRelease()
{
this.gotoAndStop("normal");
this.stopDrag();
this.onMouseMove();
delete this.onMouseMove;
}
function slider_onRollOver()
{
this.gotoAndStop("over");
}
function slider_onRollOut()
{
this.gotoAndStop("normal");
}
function getTargetSize()
{
if(this.target_height != Math.ceil(this.target_mc._height) || this.target_width != Math.ceil(this.target_mc._width))
{
this.target_height = Math.ceil(this.target_mc._height);
this.target_width = Math.ceil(this.target_mc._width);
this.update();
}
}
}